const App = getApp();

// 工具类
import Util from '../../../../utils/util.js';

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLogin: false,
    teamId: 0,
    detail: [],
    nid:0,
    peopleNum:1,
    showPopup:false,
    nowDate:Util.dateFormat('YYYY-mm-dd HH:MM', new Date()),
    theme:[],
    status:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      nid:options.nid
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let _this = this;
    _this.setData({
      isLogin: App.checkIsLogin(),
    });
    if (_this.data.isLogin) {
      _this.setData({
        teamId: App.checkTeam(),
      });

      // 详细信息
      _this.getDetail();
    }
  },

  /**
   * 详细信息
   */
  getDetail() {
    let _this = this;
    App._get('activity/detail', {activity_id:_this.data.nid}, result => {
      let themeValue=result.data.detail.theme_label
      let theme = [];
      if(themeValue){
        theme=themeValue.split(",")
      }
      _this.setData({
        detail: result.data.detail,
        theme
      })
    });
},
  //审核状态
  locationChange(e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    this.setData({
      status:e.detail.value
    })
  },
  // 弹窗
  onShowPopup(e){
    let that = this;
    that.setData({
      showPopup: !that.data.showPopup
    }); 
  },
  //提交
  formSubmit(e) {
    let formD = e.detail.value;//获取表单数据
    let obj ={
      activity_id:this.data.nid,
      status:this.data.status,
      remark:formD.remark,
    }
    console.log(obj);
    let that =this
    App._post_form('activity/examine', obj, result => {
      //成功提示
      App.showSuccess(result.msg, function() {
        that.setData({
          showPopup: false
        }); 
        wx.navigateTo({
          url: '/pages/user/activity/approve/index', //审核列表页
        })
      });

    });
  },

})